
package nightlife_reservation.Controllers;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;

import nightlife_reservation.Dao.IRegisterDao;
import nightlife_reservation.Exceptions.DaoException;
import nightlife_reservation.Models.Register;



public class RegisterController {
    
    private final IRegisterDao registerDao;
    
    
    public RegisterController(IRegisterDao registerDao){
        this.registerDao= registerDao;
    }


    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RegisterController other = (RegisterController) obj;
        if (this.registerDao != other.registerDao && (this.registerDao == null || !this.registerDao.equals(other.registerDao))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 19 * hash + (this.registerDao != null ? this.registerDao.hashCode() : 0);
        return hash;
    }
    

    public void ValitadeRegister(String Id, String StoreName, String Name, String Surname, String Phone, String Email, String Address, String City, String Floors, String Position, String Parking, String ParkingSpots, String Dates, String Username, String Password, String Repass) throws IllegalArgumentException, DaoException{

        if (Name.length() > 15) {
            JOptionPane.showMessageDialog(null,"Customer name should be at least 15 characters long" );
        }
        if (Id.isEmpty()||  Name.isEmpty() || Surname.isEmpty() || Email.isEmpty() || StoreName.isEmpty() || Address.isEmpty()|| Phone.isEmpty() || Floors.isEmpty()|| City.isEmpty() || Position.isEmpty()|| ParkingSpots.isEmpty()|| Dates.isEmpty() || Username.isEmpty()||Parking.isEmpty() || Password.isEmpty() || Repass.isEmpty())
        {
            JOptionPane.showMessageDialog(null,"There Is An Or Many Empty Field, Please Try Again");
        }
        else if (!Email.contains("@") || !Email.contains("."))
        {
            JOptionPane.showMessageDialog(null,"Wrong Email");
        }
        else if (Phone.length() > 10 || Phone.length()<10)
        {
            JOptionPane.showMessageDialog(null, "Wrong Phone Number");
        }
        else if (Phone.matches("[0-9]+") == false )
        {
              JOptionPane.showMessageDialog(null,"Your Phone Contains a non digit character");
        }
        else if (Floors.length() > 0 || Floors.length()<4)
        {
            JOptionPane.showMessageDialog(null, "Wrong number of floors");
        }
        else if (Floors.matches("[0-9]+") == false )
        {
              JOptionPane.showMessageDialog(null,"Floors is a non digit character");
        }
        else if (Position.length() > 0 || Position.length()<2001)
        {
            JOptionPane.showMessageDialog(null, "Wrong number of positions");
        }
        else if(Position.matches("[0-9]+")== false)
        {
              JOptionPane.showMessageDialog(null,"Position is not a digit character");
        }
        else if (ParkingSpots.matches("[0-9]+")== false)
        {
               JOptionPane.showMessageDialog(null,"Parking spots is not a digit character");
        }
        else if(Id.matches("[0-9]+") == false)
        {
              JOptionPane.showMessageDialog(null,"ID is not a digit character");
        }
        else if(Parking == "YES" || Parking=="NO" || Parking=="yes"||Parking=="no"|| Parking=="Yes"|| Parking=="No")
        {
                JOptionPane.showMessageDialog(null,"Parking must be: YES or NO or yes or no or Yes or No");
        }
        else if (!Password.equals(Repass))
        {
            JOptionPane.showMessageDialog(null,"Your Password and Repass do not match");
        }
        else 
        {
            JOptionPane.showMessageDialog(null,"Sign-Up Successful");
            
        }
    }

}
